#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1e6 + 5;

int n, m;
int a[N], cnt[N];

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  rep(i, 1, n) cin >> a[i];
  rep(i, 1, n) cnt[a[i]]++;
  per(i, 1e6, 1) for (int j = i * 2; j <= 1e6; j += i) cnt[j] += cnt[i];
  rep(i, 1, n) cout << cnt[a[i]] - 1 << endl;
  return 0;
}